#include<stdio.h>
#include<stdlib.h>
using namespace std;
typedef struct node{
    struct node *next;
    int data;
}*list;
list create(list head){
    if(head==NULL){
        head=(list)malloc(sizeof(struct node));
        head->next=NULL;
    }
    int x;
    list p=head;
    scanf("%d",&x);
    while(x!=-1){//尾插法
        list node=(list)malloc(sizeof(struct node));
        node->data=x;
        node->next=NULL;
        p->next=node;
        p=node;
        scanf("%d",&x);
        // head->next=node;
    }
    return head;
}
void fun(list head){
    list p,q;
    p=head->next;
    q=p->next;
    while (q)
    {
        list node=(list)malloc(sizeof(struct node));
        node->data=p->data+q->data;
        node->next=q;
        p->next=node;
        p=q;
        q=q->next;
    }
}
void printList(list head){
    list p=head->next;
    while(p){
        printf("%d->",p->data);
        p=p->next;
    }
}
int main(){
    list head=NULL;
    head=create(head);
    printList(head);
    fun(head);
    printf("\n-----------\n");
    printList(head);
    return 0;
}